<template>
  <d-scroll-view  @refresherrefresh="getDetail" :refresher-triggered="triggered">
    <proj-detail-layout ref="projDetailLayout" :process-instance-id="processInstanceId" :project-number="projectNumber">
    <d-forms label-width="190rpx">
      <d-forms-item label="迭代序列" :input="form.idx"></d-forms-item>
      <d-forms-item label="版本号" :input="form.versionNum"></d-forms-item>
      <d-forms-item label="版本设计人" :input="form.designerName"></d-forms-item>
      <d-forms-item label="原型更新时间" :type="DFormInputType.DATE" :input="form.prototypeUpdateTime"></d-forms-item>
      <d-forms-item label="原型地址" :input="form.prototype"></d-forms-item>
      <view>
        <view class="form-title-1">版本内容</view>
        <d-card>
          <d-forms-item disabled :input="form.content"></d-forms-item>
        </d-card>
      </view>
      <view>
        <view class="form-title-1">原型附件</view>
        <d-card>
          <pm-file-upload readonly :files="form.prototypeAttach"></pm-file-upload>
        </d-card>
      </view>
      <view>
        <view class="form-title-1">版本功能清单</view>
        <d-card>
          <pm-file-upload readonly :files="form.functionList"></pm-file-upload>
        </d-card>
      </view>
      <view>
        <view class="form-title-1">备注</view>
        <d-card>
          <d-forms-item disabled :input="form.remarks"></d-forms-item>
        </d-card>
      </view>
    </d-forms>
  </proj-detail-layout>
  </d-scroll-view>
</template>

<script setup lang="ts">
import ProjDetailLayout from "@/components/ProjDetailLayout/index.vue";
import {useSoftwareVersionApi} from "@/api/pm/project/softwareVersion";
import {DFormInputType} from "@/utils/enum";

defineOptions({ name: 'SoftwareVersionApply'})

const initForm = {
  traceId: null,
  projectNumber: null,
  versionNum: null,
  content: null,
  prototype: null,
  prototypeUpdateTime: null,
  prototypeAttach: null,
  functionList: null,
  remarks: null,
  storaged: null,
  id: null,
  idx: null,
  designer: null,
  designerName: null,
  processInstanceId: null,
  result: null,
  reason: null,
  approvalTime: null,
  updater: null,
  updaterName: null,
  updateTime: null,
  status: null,
  statusName: null,
}
const form = ref<SoftwareVersionForm>(initForm)
const triggered = ref<boolean>(false);
function getDetail() {
  if (processInstanceId.value) {
    triggered.value = true;
    useSoftwareVersionApi().getProductVersionByProcess(processInstanceId.value).then(res => {
      if (res.code === 0) {
        form.value = res.data || initForm
      }
    }).finally(() => {
      triggered.value = false;
    })
  }
}

const projectNumber = ref<string>(null);
const processInstanceId = ref<string>(null);
onLoad((query) => {
  projectNumber.value = query['project_number']
  processInstanceId.value = query['process_instance_id']
  getDetail();
})
</script>

<style scoped lang="scss">

</style>
